class CreateUsuarios < ActiveRecord::Migration
  def self.up
    create_table :usuarios do |t|
      t.references :tipo_usuario
      t.string :nome, :limit => 100, :null => false
      t.string :endereco, :limit => 100, :null => false 
      t.string :login, :limit => 30, :null => false 
      t.string :senha, :limit => 8, :null => false
      t.string :email, :limit => 100, :null => false
      t.string :numero, :limit => 5, :null => false
      t.string :bairro, :limit => 60, :null => false
      t.string :cidade, :limit => 60, :null => false
      t.string :cep, :limit => 8, :null => false
      t.string :complemento, :limit => 20
      t.string :telefone, :limit => 10, :null => false
      t.string :celular, :limit => 10
      t.string :cpf, :limit => 11, :null => false
      t.string :nacionalidade, :limit => 40, :null => false
      t.string :sexo, :limit => 1, :null => false
      t.string :escolaridade, :limit => 20, :null => false
      t.date :data_nascimento, :null => false
      t.date :data_atualização, :null => false
      t.date :data_cadastro, :null => false
      t.string :departamento, :limit => 60, :null => false
      t.text :descricao_profissional, :limit => 100, :null => false
      t.integer :estado_civil, :null => false
      t.string :status, :null => false
      
      t.timestamps
    end
    execute("alter table usuarios add foreign key(tipo_usuario_id) references tipo_usuarios(id)")
    
    add_index :usuarios, :login, :unique => true
    add_index :usuarios, :email, :unique => true
    add_index :usuarios, :cpf, :unique => true

    

  end

  def self.down
    drop_table :usuarios
  end
end
